package cn.tedu.design;

/**
 * @Author 金帮嘉诚
 * @Date 2021-06-10 周四 20:24
 */
/*本类用于完成OOP、汽车设计综合案例*/
public class DesignCar {
    public static void main(String[] args) {
        //Car类
        Car c=new Car();
//        c.color;
        System.out.println("c.getColor() = " + c.getColor());
        c.start();
        c.stop();
        //BMW类
        BMW b=new BMW();
        System.out.println("b.color = " + b.color);//子类的成员变量
        System.out.println("b.getColor() = " + b.getColor());//父类的成员变量
        b.start();
        b.stop();//重写
        //Porsche类
        Porsche p=new Porsche();
        System.out.println("p.color = " + p.color);;
        System.out.println("p.getColor() = " + p.getColor());
        p.start();
        p.stop();
        p.fly();//子类独有
    }
}
class Car{
    private String brand;
    private String color;
    private double price;
    private double size;

    public void start(){
        System.out.println("Start Car");
    }
    public void stop(){
        System.out.println("Stop Car");
    }


    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getSize() {
        return size;
    }

    public void setSize(double size) {
        this.size = size;
    }
}
class BMW extends Car{
    String color="宝马黑";
    @Override
    public void stop(){
        System.out.println("BMW Stop");
    }
}
class Porsche extends Car{
    String color="保时捷白";
    public void fly(){
        System.out.println("Porsche Fly");
    }
}
